﻿@model User

@{
	Layout = null;
}

<script>
	function logout() {
		$('#lightbox_shadow').show();
		$.ajax({
		type : "POST",
		url : '@Url.Action("Logout", "Login")',
		success: function (request) {
			$('#lightbox_shadow').click();
			location.reload(true)
		},

		error: function(request,error) {alert(error)}
		});
	}
</script>

<div id="header_leftCol">
	<div id="logo_container">
			<h1 id="logo"><a href="@Url.Action("Index", "Home")">Клуб небезразличных людей</a></h1>
			<h2 id="logo_slogan">Мы встречаемся и делаем вместе интересные и полезные дела!</h2>
	</div>
</div>
<div id="header_rightCol_outer">
	<div id="header_rightCol">

        <div id="headerNavigator_container">
			<ul id="headerNavigator">
			@if(Model == null) {
	        <li class="headerNavigator_item"><a href="#" class="showLightBox_link" rel="registerBox">Регистрация</a></li>
	        <li class="headerNavigator_item"><a href="#" class="showLightBox_link" rel="loginBox">Войти</a> 
                (можно через
				<a href="@Url.Action("SendRequest", "GoogleLogin", new { callbackUri = Request.Url.AbsoluteUri })"> <img src="@Url.Content("~/Content/img/logo/google.jpg")" alt="Google" class = "socialNetworkLogo"/></a>

				<a href="@Url.Action("SendRequest", "FacebookLogin", new { callbackUri = Request.Url.AbsoluteUri })"> <img src="@Url.Content("~/Content/img/logo/facebook-16.gif")" alt="Facebook" class = "socialNetworkLogo"/></a>

				<a href="@Url.Action("SendRequest", "VkontakteLogin", new { callbackUri = Request.Url.AbsoluteUri })"> <img src="@Url.Content("~/Content/img/logo/vkontakte-16.png")" alt="Вконтакте" class = "socialNetworkLogo"/></a>
                )
            </li>
	           }
	           else
	           {
	        <li class="headerNavigator_item"><a href="#" onclick="logout()">Выйти</a></li>
	        <li class="headerNavigator_item">@(Html.ActionLink<UserController>(x => x.View(Model.Id), Model.DisplayName ?? "unknown"))</li>
            <li class="headerNavigator_item"><a href="#" class="showLightBox_link" rel="notificationSettingsBox">Настройка уведомлений</a></li>
               }

		        <li class="headerNavigator_item">
                @if (Model != null)
                {
                <a href="#" class="showLightBox_link" rel="createIdeaBox">Предложить проект</a>
                }
                else
                {
                <a href="#" class="showLightBox_link" rel="registerOrLogInBox">Предложить проект</a>
                }
                </li>
              
		        @if (Model != null && Model.IsAdmin)
          {

              var IdeasLinkText = "Неутверждённые проекты";
              var IdeasLinkStyle = "";
              if (ViewBag.IdeasCount > 0)
              {
                  IdeasLinkText = String.Format("Неутверждённые проекты ({0})", ViewBag.IdeasCount);
                  IdeasLinkStyle = "font-weight:bold";
              }
			        <li class="headerNavigator_item">
                        @(Html.ActionLink<IdeaController>(x => x.Index(), IdeasLinkText, new { style = IdeasLinkStyle }))
                    </li>
			        <li class="headerNavigator_item">@(Html.ActionLink<InflectionController>(x => x.Index(), "Таблица склонений"))</li>
                    <li class="headerNavigator_item">@(Html.ActionLink<NewsController>(x => x.Add(), "Добавить новость"))</li>
          }
		        @*<li class="headerNavigator_item"><a href="#">Подробнее о нас</a></li>*@
				<li class="headerNavigator_item">Написать разработчикам: <strong>vol-portal@googlegroups.com</strong></li>
	        </ul>
        </div>

    </div>
</div>

<div id="lightbox_shadow">&nbsp;</div>
@Html.Partial("CreateIdeaView", null, new ViewDataDictionary())

@Html.Partial("RegisterView", null, new ViewDataDictionary())
@Html.Partial("RegisterOrLoginView", null, new ViewDataDictionary())
@Html.Partial("LoginView", null, new ViewDataDictionary())
@if (Model != null)
{
@Html.Partial("NotificationSettingsView", new Web.ViewModels.NotificationSettingsModel(Model), new ViewDataDictionary())
}

<script type="text/javascript">
	$(document).ready(function () {
		$('#loginBoxForm')[0].success = xxx($('#loginBoxForm'));
		$('#registerBoxForm')[0].success = xxx($('#registerBoxForm'));
		function xxx(jf) {
			return function success(data) {
				if (data != null && data.ErrorMessage != null)
					jf.children(".errorMessage").html(data.ErrorMessage);
				else {
					$('#lightbox_shadow').click();
					window.location = data.RedirectUrl;
				}
			};
		}
	});
</script>